package com.ecomemerce.app.comment.widgets

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
@Stable
fun ProductsPreferred(){
    Column(
        modifier = Modifier
            .fillMaxWidth()
            .padding(8.dp)
            .background(Color(0xFFFFE4E1), shape = RoundedCornerShape(8.dp))

    ) {
        // 顶部标题栏
        Row(
            modifier = Modifier.fillMaxWidth(),
            horizontalArrangement = Arrangement.SpaceBetween
        ) {
            Text(
                text = "",
                fontWeight = FontWeight.Bold,
                fontSize = 18.sp,
                color = Color(0xFFD32F2F) // 主题红色
            )
            Text(
                text = "更多 >>",
                fontSize = 14.sp,
                color = Color(0xFFD32F2F),
                modifier = Modifier.padding(end = 8.dp, top = 10.dp).clickable { /* TODO: 更多点击事件 */ }
            )
        }

        Spacer(modifier = Modifier.height(8.dp))

        // 横向滚动商品列表
        LazyRow {
            items(getProducts()) { product ->
                ProductCard(product)
            }
        }
    }
}

// 商品数据类
data class Product1(val name: String, val price: String, val originalPrice: String, val imageUrl: String)

// 模拟数据
fun getProducts(): List<Product1> {
    return listOf(
        Product1("乐事薯片", "85.20 AED", "103.00 AED", "https://example.com/chips.jpg"),
        Product1("胡姬花生橙", "85.20 AED", "103.00 AED", "https://example.com/orange.jpg"),
        Product1("山竹剥壳", "85.20 AED", "103.00 AED", "https://example.com/vegetable.jpg"),
    )
}